home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / chqflag.c < prev    next >
C/C++ Source or Header  |  2000-03-26  |  3KB  |  127 lines

  1. /***************************************************************************
  2.  
  3.   vidhrdw.c
  4.  
  5.   Functions to emulate the video hardware of the machine.
  6.  
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10. #include "vidhrdw/generic.h"
  11. #include "vidhrdw/konamiic.h"
  12. #include "cpu/z80/z80.h"
  13.  
  14. #define SPRITEROM_MEM_REGION REGION_GFX1
  15. #define ZOOMROM0_MEM_REGION REGION_GFX2
  16. #define ZOOMROM1_MEM_REGION REGION_GFX3
  17.  
  18. int sprite_colorbase,zoom_colorbase[2];
  19.  
  20. /***************************************************************************
  21.  
  22.   Callbacks for the K051960
  23.  
  24. ***************************************************************************/
  25.  
  26. static void sprite_callback(int *code,int *color,int *priority)
  27. {
  28. //    *code |= (*color & 0x80) << 6;
  29.     *color = sprite_colorbase + (*color & 0x0f);
  30. }
  31.  
  32.  
  33. /***************************************************************************
  34.  
  35.   Callbacks for the K051316
  36.  
  37. ***************************************************************************/
  38.  
  39. static void zoom_callback_0(int *code,int *color)
  40. {
  41.     *code |= ((*color & 0x03) << 8);
  42.     *color = zoom_colorbase[0] + ((*color & 0x3c) >> 2);
  43. }
  44.  
  45. static void zoom_callback_1(int *code,int *color)
  46. {
  47.     tile_info.flags = TILE_FLIPYX((*color & 0xc0) >> 6);
  48.     *code |= ((*color & 0x0f) << 8);
  49.     *color = zoom_colorbase[1] + ((*color & 0x30) >> 4);
  50. }
  51.  
  52. /***************************************************************************
  53.  
  54.     Start the video hardware emulation.
  55.  
  56. ***************************************************************************/
  57.  
  58. int chqflag_vh_start( void )
  59. {
  60.     sprite_colorbase = 0;
  61.     zoom_colorbase[0] = 0x10;
  62.     zoom_colorbase[1] = 0x04;    /* not sure yet, because of bad dumps */
  63.  
  64.     if (K051960_vh_start(SPRITEROM_MEM_REGION,NORMAL_PLANE_ORDER,sprite_callback))
  65.     {
  66.         return 1;
  67.     }
  68.  
  69.     if (K051316_vh_start_0(ZOOMROM0_MEM_REGION,4,zoom_callback_0))
  70.     {
  71.         K051960_vh_stop();
  72.         return 1;
  73.     }
  74.  
  75.     if (K051316_vh_start_1(ZOOMROM1_MEM_REGION,7,zoom_callback_1))
  76.     {
  77.         K051960_vh_stop();
  78.         K051316_vh_stop_0();
  79.         return 1;
  80.     }
  81.  
  82.     K051316_set_offset(0, 8, 0);
  83.     K051316_wraparound_enable(1, 1);
  84.  
  85.     return 0;
  86. }
  87.  
  88. void chqflag_vh_stop( void )
  89. {
  90.     K051960_vh_stop();
  91.     K051316_vh_stop_0();
  92.     K051316_vh_stop_1();
  93. }
  94.  
  95. /***************************************************************************
  96.  
  97.     Display Refresh
  98.  
  99. ***************************************************************************/
  100.  
  101. void chqflag_vh_screenrefresh( struct osd_bitmap *bitmap, int fullrefresh )
  102. {
  103.     int i;
  104.  
  105.     K051316_tilemap_update_0();
  106.     K051316_tilemap_update_1();
  107.  
  108.     palette_init_used_colors();
  109.     K051960_mark_sprites_colors();
  110.  
  111.     /* set back pen for the zoom layer */
  112.     for (i = 0; i < 16; i++){
  113.         palette_used_colors[(zoom_colorbase[0] + i) * 16] = PALETTE_COLOR_TRANSPARENT;
  114.     }
  115.  
  116.     if (palette_recalc())
  117.         tilemap_mark_all_pixels_dirty(ALL_TILEMAPS);
  118.  
  119.     tilemap_render(ALL_TILEMAPS);
  120.  
  121.     fillbitmap(bitmap,Machine->pens[0],&Machine->drv->visible_area);
  122.  
  123.     K051316_zoom_draw_1(bitmap,0);
  124.     K051960_sprites_draw(bitmap,0,128);
  125.     K051316_zoom_draw_0(bitmap,0);
  126. }
  127.